from django.shortcuts import render

# Create your views here.
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated

from address.models import Address
from address.serializers import AddressListSerializer, CreateAddressSerializer


class AddressViewset(viewsets.ModelViewSet):
    permission_classes = [IsAuthenticated]

    def get_serializer_class(self):
        if self.action == "create":
            return CreateAddressSerializer
        return AddressListSerializer

    def get_queryset(self):
        return Address.objects.filter(user=self.request.user, is_deleted=False)
